package webday04;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class LoginServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//post请求会产生乱码，先转
		req.setCharacterEncoding("utf-8");
		
		//登陆成功后，需要把用户信息放到session里面去
		String username=req.getParameter("name");
		
		System.out.println(username);
		
		//把用户名放入吧session
		HttpSession session=req.getSession();
		session.setAttribute("user", username);
		
		//跳到user.jsp
		req.getRequestDispatcher("user.jsp").forward(req, resp);
	}
	
	
}
